<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">

$(document).ready(function() {
	var arguments = window.dialogArguments;
	var selectorname = arguments[0];
	var selectordesc = arguments[1];
	var selectorvalue = arguments[2];
	var getSelectorUrl = "/special/"+ selectorname +"/getList/";
	$.ajax({
			   type: "GET",
			   url: getSelectorUrl,
			   data: "",
			   dataType: "json",
			   success: function(data) {
				   if(data.code > 0) {
					   fillselect(s2json(data.result));
					   $("#selectorlabel").html(selectordesc);
					   if(selectorvalue) {
						   $("#selector").val(selectorvalue);
					   }
				   }else {
					   alert(data.message);
				   }
			   }
		});
});

function fillselect(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#selector").html(optionHTML);
}

function submitSelector() {
	var value = $("#selector").val();
	var text = $("#selector option:selected").text();
	window.returnValue = [value,text];
	beforeWindowClose();
	window.close();
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}
</script>

<body onunload="beforeWindowClose()">
<div class="addarea">
<label id="selectorlabel" for="selector"></label>
<select id="selector">

</select>
<input type="button" onclick="submitSelector()" value="提交"/>
</div>
</body>